<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>用户管理</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link href="${ctx }/css/style.css" type="text/css" rel="stylesheet" />
		<link href="${ctx }/css/page.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="${ctx }/js/jquery/jquery-1.6.1.min.js"></script>
		<script type="text/javascript">
			$(function() {
				$("#userRole").change(function() {
					$("form:first").submit();
				});

				$("#chkSelectAll").click(function() {
					$("input[name=ids]").each(function() {
						 $(this).attr("checked", !this.checked);              
					});
				});

				$("#btnPass").click(function() {
					var size = $("input[name=ids]:checked").size();

					if (size == 0) {
						alert("请选择要操作的用户！");
					} else {
						var form = $("form:first");
						form.attr("action", "${ctx}/user/passWatingApproveUser.action");
						form.submit();
						form.attr("action", "${ctx}/user/listUsers.action");
					}
				});

				$("#btnVip").click(function() {
					var size = $("input[name=ids]:checked").size();

					if (size == 0) {
						alert("请选择要操作的用户！");
					} else {
						var form = $("form:first");
						form.attr("action", "${ctx}/user/changeUserToVIP.action");
						form.submit();
						form.attr("action", "${ctx}/user/listUsers.action");
					}
				});

				$("#btnAdmin").click(function() {
					var size = $("input[name=ids]:checked").size();

					if (size == 0) {
						alert("请选择要操作的用户！");
					} else {
						var form = $("form:first");
						form.attr("action", "${ctx}/user/changeUserToAdmin.action");
						form.submit();
						form.attr("action", "${ctx}/user/listUsers.action");
					}
				});

				$("#btnDisabledUser").click(function() {
					var size = $("input[name=ids]:checked").size();

					if (size == 0) {
						alert("请选择要操作的用户！");
					} else {
						var form = $("form:first");
						form.attr("action", "${ctx}/user/disabledUsers.action");
						form.submit();
						form.attr("action", "${ctx}/user/listUsers.action");
					}
				});
			});

			viewUserDetail = function(id) {
				window.showModalDialog("${ctx}/user/viewUserDetail.action?id=" + id,"","status=no;dialogWidth=380px;dialogHeight=450px;menu=no;resizeable=yes;scroll=yes;center=yes;edge=raise");
			}
		</script>
	</head>
	<body>
		<s:form id="form1" action="listUsers" method="post" namespace="/user">
			<div>
				<div style="width: 100%; height: 30px; text-align: left;">
					当前位置：用户管理
				</div>
				<div
					style="width: 100%; background-color: #EDDEA0; height: 30px; border: 1px solid gray; text-align: center;">
					<b>用 户 管 理</b>
				</div>

				<div
					style="width: 100%; background-color: #EDDEA0; height: 39px; border: 1px solid gray; text-align: center;">
					<div style="float: left; width: 10%; padding-top: 6px">
						<input type="checkbox" id="chkSelectAll" />
						全选
					</div>
					<div style="float: left; width: 43%; padding-top: 6px;">
						<span>用户类型：</span>
						<s:select id="userRole" list="#{-1:'所有用户',1:'超级管理员',2:'VIP用户',3:'普通会员',4:'待审核人员'}" 
							name="userRole" cssStyle="width: 136px;"></s:select>
					</div>
					<div
						style="float: left; width: 45%; text-align: left; padding-top: 6px;">
						&nbsp;&nbsp;
						<img alt="" src="${ctx }/images/user.gif"
							style="text-align: justify; border: 0" />
						&nbsp;
						<input type="button" id="btnPass" style="cursor: hand; width: 184px; height: 20px;"
							value="通过审核，设置为普通会员" />
					</div>
				</div>

				<div style="width: 100%; background-color: #FBF7E6; text-align: center;">
					<div>
						<table cellspacing="2" cellpadding="3" border="1" style="background-color: #FFF7E7; border-color: #DEBA84; border-width: 1px; border-style: None; width: 100%;">
							<thead>
								<tr style="color: White; background-color: #A55129; font-weight: bold; font-size: 11px;">
									<th style="width: 15%;">选定（√）</th>
									<th>用户名</th>
									<th>密码</th>
									<th>角色</th>
									<th>用户详情</th>
								</tr>
							</thead>
							<tbody>
								<s:if test="page.data.size() == 0">
									<tr style="color: #000066; background-color: #FFF7E7; font-size: 13px; text-align: center;">
										<td colspan="5">没有满足条件的数据！</td>
									</tr>
								</s:if>
								<s:else>
									<s:iterator value="page.data">
										<tr style="color: #000066; background-color: #FFF7E7;">
											<td>
												<input type="checkbox" name="ids" value='<s:property value="id" />' />
											</td>
											<td>
												<s:property value="username" />
											</td>
											<td>
												<s:property value="password" />
											</td>
											<td>
												<s:property value="%{@com.gamecard.util.DisplayUtil@formatUserRole(userRole)}" />
											</td>
											<td>
												<span style="color: blue;">
													<a href="#" onclick="viewUserDetail('<s:property value="id" />');">查看详细</a>
												</span>
											</td>
										</tr>
									</s:iterator>
								</s:else>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="5" align="center">
										<gc:page pageSize="${page.pageSize}" 
											totalCount="${page.totalCount}" 
											formId="form1" 
											totalPageCount="${page.totalPageCount}" 
											currentPageNo="${page.currentPageNo}" />
									</td>
								</tr>
							</tfoot>							
						</table>
					</div>
				</div>
				<div style="width: 100%; height: 10px; background-color: #FBF7E6"></div>
				<div style="width: 100%;">
					<div style="float: left; width: 30%">
						&nbsp;&nbsp;
						<input type="button" id="btnDisabledUser" style="cursor: hand; height: 22px; width: 82px;" value="屏蔽选定用户" />
					</div>
					<div style="float: left; width: 66%">
						&nbsp;&nbsp;
						<img alt="" src="${ctx }/images/vip.gif" style="text-align: justify; border: 0" />
						&nbsp;
						<input type="button" id="btnVip" style="cursor: hand; width: 103px; height: 19px;" value="升级为VIP会员" />
						&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
						<img alt="" src="${ctx }/images/xx.gif" style="text-align: justify; border: 0; vertical-align: bottom; width: 21px;" />
						&nbsp;
						<input type="button" id="btnAdmin" style="cursor: hand; width: 78px; height: 20px;" value="加为管理员" />
					</div>
				</div>
			</div>
         &nbsp;   
    </div>
			</div>
		</s:form>
	</body>
</html>
